package com.sds.shop.action;

import java.io.IOException;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

import com.sds.fw.mvc.Action;
import com.sds.fw.mvc.HttpUtil;
import com.sds.shop.dao.MemDAO;
import com.sds.shop.vo.MemVO;
import com.sds.shop.vo.SessionVO;

public class MyInfoEditAction extends Action 
{
	@Override
	public void execute(HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException {
		String path;
		MemDAO dao = new MemDAO();
		MemVO mv = new MemVO();
		String id = request.getParameter("mem_id");
		mv.setMemId(id);
		mv.setMemNm(request.getParameter("mem_nm"));
		mv.setPwd(request.getParameter("pwd"));
		mv.setPwdHint(request.getParameter("pwd_hint"));
		mv.setPwdHintAns(request.getParameter("pwd_hint_ans"));
		mv.setSsn(request.getParameter("ssn"));
		String birthyear = request.getParameter("birthyear");
		String birthmonth = request.getParameter("birthmonth");
		String birthday = request.getParameter("birthday");

		if (birthmonth.length() == 1) {
			birthmonth = "0" + birthmonth;
		}
		if (birthday.length() == 1) {
			birthday = "0" + birthday;
		}
		String birth = birthyear+birthmonth+birthday;
		mv.setBirthDt(birth);
		mv.setMaleFlg(request.getParameter("se"));
		mv.setTelNo(request.getParameter("tell_no"));
		mv.setCellNo(request.getParameter("cell_no"));
		mv.setAddr(request.getParameter("addr"));
		mv.setEmail(request.getParameter("email"));
		mv.setEmailRcvFlg(request.getParameter("email_yn"));
		dao.editCustomer(id, mv);
		request.setAttribute("myInformationedit", mv);
		path = "/jsp/myinfoedit.jsp";
		HttpUtil.forward(request, response, path);
	}
}
